﻿package mortal.game.scene3D.layer3D.utils
{
    import __AS3__.vec.*;
    import com.gengine.utils.*;
    import flash.utils.*;
    import mortal.common.sound.*;
    import mortal.game.*;
    import mortal.game.model.*;
    import mortal.game.scene3D.layer3D.*;
    import mortal.game.scene3D.player.entity.*;

    public class EffectSoundUtil extends EntityLayerUtil
    {
        private var _map:Dictionary;

        public function EffectSoundUtil(param1:PlayerLayer)
        {
            this._map = new Dictionary();
            super(param1);
            return;
        }// end function

        override public function removeAll() : void
        {
            var _loc_1:String = null;
            for each (_loc_1 in this._map)
            {
                
                SoundManager.instance.removeEffectMusic(_loc_1);
            }
            this._map = new Dictionary();
            return;
        }// end function

        override public function updateEntity() : void
        {
            var _loc_4:MusicAreaInfo = null;
            var _loc_5:Number = NaN;
            var _loc_6:Boolean = false;
            var _loc_7:Number = NaN;
            if (!Game.sceneInfo)
            {
                return;
            }
            var _loc_1:* = Game.sceneInfo.musicAreas;
            if (_loc_1.length < 1)
            {
                return;
            }
            var _loc_2:* = RolePlayer.instance.x2d;
            var _loc_3:* = RolePlayer.instance.y2d;
            for each (_loc_4 in _loc_1)
            {
                
                _loc_5 = MathUitl.getDistance(_loc_2, _loc_4.point.x, _loc_3, _loc_4.point.y);
                _loc_6 = _loc_5 < _loc_4.r2;
                if (_loc_6)
                {
                    _loc_7 = 1;
                    if (_loc_5 > _loc_4.r1)
                    {
                        _loc_7 = 0 + (_loc_4.r2 - _loc_5) / (_loc_4.r2 - _loc_4.r1) * 1;
                    }
                    SoundManager.instance.playEffectMusic(_loc_4.url, _loc_7);
                    this._map[_loc_4.url] = _loc_4.url;
                    continue;
                }
                SoundManager.instance.removeEffectMusic(_loc_4.url);
            }
            return;
        }// end function

    }
}
